Skip to content

fix: compare prerelease versions against previous stable for size diff#2324

Merged
ghostdevv merged 2 commits intonpmx-dev:mainfrom
joshuaisaact:fix/prerelease-size-comparison
Apr 4, 2026
Merged

fix: compare prerelease versions against previous stable for size diff#2324
ghostdevv merged 2 commits intonpmx-dev:mainfrom
joshuaisaact:fix/prerelease-size-comparison

Conversation

@joshuaisaact
Copy link
Copy Markdown
Contributor

@joshuaisaact joshuaisaact commented Mar 30, 2026

🔗 Linked issue

Resolves #2313

🧭 Context

When viewing an old prerelease version (e.g. oxlint@1.17.0-alpha.0), it compared against the latest version (in oxlint's case this was 1.57.0), not the stable version before the prerelease.

Since the latest version is newer and smaller, this showed a "size increase" warning on the old alpha. The package size of oxlint has decreased in newer versions, but we shouldn't say that the old alpha has 'increased'.

We should be comparing the old alpha against the closest previous stable.

📚 Description

I changed the prerelease comparison logic in getComparisonVersion to find the previous stable version in semver order, the same approach already used for stable versions.

The old code used the latest dist-tag as a shortcut, which broke when viewing prereleases older than latest.

The old prerelease behavior was:

  1. Look up latest dist-tag
  2. If no latest or prerelease IS latest, return null
  3. Otherwise compare against latest

The new behavior is:

Find the highest stable version before this prerelease, in semver order.

Which matches the non-alpha behaviour, removing the (bugged) shortcut.

Also updated the tests while I was there, because I am nice.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs.npmx.dev Ready Ready Preview, Comment Apr 4, 2026 8:30pm
npmx.dev Ready Ready Preview, Comment Apr 4, 2026 8:30pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
npmx-lunaria Ignored Ignored Apr 4, 2026 8:30pm

Request Review

@github-actions
Copy link
Copy Markdown

Hello! Thank you for opening your first PR to npmx, @joshuaisaact! 🚀

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any issues you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Vercel

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

The changes update the prerelease version comparison logic in getComparisonVersion. Previously, when dealing with a prerelease version, the function returned the packument's dist-tags.latest tag value. The updated implementation now constructs a filtered, semver-sorted list of stable versions and returns the highest stable version with a lower version number than the prerelease. Non-prerelease version handling remains unchanged. Corresponding test cases were updated to reflect this new prerelease comparison behaviour.

Possibly related PRs

Suggested reviewers

  • ghostdevv
  • danielroe
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly relates to and explains the changeset, detailing the bug fix for prerelease version comparison logic and the rationale for the changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ghostdevv ghostdevv enabled auto-merge April 4, 2026 20:29
@ghostdevv ghostdevv added this pull request to the merge queue Apr 4, 2026
Merged via the queue into npmx-dev:main with commit 064cf97 Apr 4, 2026
20 checks passed
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

Thanks for your first contribution, @joshuaisaact! 🤩

We'd love to welcome you to the npmx community. Come and say hi on Discord! And once you've joined, visit npmx.wamellow.com to claim the contributor role.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Size increase" warning shows up incorrectly for alpha versions that are older and smaller than the latest release

2 participants